package com.mia.props.client.container.guilib;

public class GuiToggleButton extends GuiElement implements IGuiHandlesMouseClick, IGuiRenderable {
   private int[] textureUVs;
   protected boolean toggledOn;

   public GuiToggleButton(IExposedGui parent, int x, int y, int width, int height, int[] iconUVs, boolean toggledOn) {
      super(parent, x, y, width, height);
      this.textureUVs = iconUVs;
      this.toggledOn = toggledOn;
   }

   public boolean isToggledOn() {
      return this.toggledOn;
   }

   public void render(int mouseX, int mouseY) {
      if (this.mouseOver(mouseX, mouseY)) {
         if (this.toggledOn) {
            this.parent.getGui().drawTexturedModalRect(this.posX(), this.posY(), this.textureUVs[6], this.textureUVs[7], this.width_element, this.height_element);
         } else {
            this.parent.getGui().drawTexturedModalRect(this.posX(), this.posY(), this.textureUVs[2], this.textureUVs[3], this.width_element, this.height_element);
         }
      } else if (this.toggledOn) {
         this.parent.getGui().drawTexturedModalRect(this.posX(), this.posY(), this.textureUVs[4], this.textureUVs[5], this.width_element, this.height_element);
      } else {
         this.parent.getGui().drawTexturedModalRect(this.posX(), this.posY(), this.textureUVs[0], this.textureUVs[1], this.width_element, this.height_element);
      }

   }

   protected void mouseClickedCallback(int mouseButton) {
   }

   public void mouseClicked(int mouseButton) {
      this.toggledOn = !this.toggledOn;
      this.mouseClickedCallback(mouseButton);
   }
}
